home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / MPW Related / MPW Interfaces / CIncludes / TextEdit.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  11.9 KB  |  374 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TextEdit.h
  3.  
  4.     Copyright:    © 1983-1993 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Version:    System 7.1 for ETO #11
  8.     Created:    Tuesday, March 30, 1993 18:00
  9.  
  10. */
  11.  
  12. #ifndef __TEXTEDIT__
  13. #define __TEXTEDIT__
  14.  
  15. #ifndef __QUICKDRAW__
  16. #include <Quickdraw.h>
  17. #endif
  18.  
  19.  
  20. enum {
  21.  
  22.  
  23. /* Justification (word alignment) styles */
  24.  teJustLeft = 0,
  25.  teJustCenter = 1,
  26.  teJustRight = -1,
  27.  teForceLeft = -2,
  28.  
  29. /* new names for the Justification (word alignment) styles */
  30.  teFlushDefault = 0,                                    /*flush according to the line direction */
  31.  teCenter = 1,                                            /*center justify (word alignment) */
  32.  teFlushRight = -1,                                        /*flush right for all scripts */
  33.  teFlushLeft = -2,                                        /*flush left for all scripts */
  34.  
  35. /* Set/Replace style modes */
  36.  fontBit = 0,                                            /*set font*/
  37.  faceBit = 1,                                            /*set face*/
  38.  sizeBit = 2,                                            /*set size*/
  39.  clrBit = 3,                                            /*set color*/
  40.  addSizeBit = 4,                                        /*add size mode*/
  41.  toggleBit = 5,                                            /*set faces in toggle mode*/
  42.  toglBit = 5,                                            /* obsolete.  use toggleBit */
  43.  
  44. /* TESetStyle/TEContinuousStyle modes */
  45.  doFont = 1,                                            /* set font (family) number*/
  46.  doFace = 2,                                            /*set character style*/
  47.  doSize = 4,                                            /*set type size*/
  48.  doColor = 8,                                            /*set color*/
  49.  doAll = 15,                                            /*set all attributes*/
  50.  addSize = 16                                            /*adjust type size*/
  51. };
  52. enum {
  53.  doToggle = 32,                                            /*toggle mode for TESetStyle & TEContinuousStyle*/
  54.  
  55. /* offsets into TEDispatchRec */
  56.  EOLHook = 0,                                            /*[ProcPtr] TEEOLHook*/
  57.  DRAWHook = 4,                                            /*[ProcPtr] TEWidthHook*/
  58.  WIDTHHook = 8,                                            /*[ProcPtr] TEDrawHook*/
  59.  HITTESTHook = 12,                                        /*[ProcPtr] TEHitTestHook*/
  60.  nWIDTHHook = 24,                                        /*[ProcPtr] nTEWidthHook*/
  61.  TextWidthHook = 28,                                    /*[ProcPtr] TETextWidthHook*/
  62.  
  63. /* selectors for TECustomHook */
  64.  intEOLHook = 0,                                        /*TEIntHook value*/
  65.  intDrawHook = 1,                                        /*TEIntHook value*/
  66.  intWidthHook = 2,                                        /*TEIntHook value*/
  67.  intHitTestHook = 3,                                    /*TEIntHook value*/
  68.  intNWidthHook = 6,                                        /*TEIntHook value for new version of WidthHook*/
  69.  intTextWidthHook = 7,                                    /*TEIntHook value for new TextWidthHook*/
  70.  
  71. /* feature or bit definitions for TEFeatureFlag */
  72.  teFAutoScroll = 0,                                        /*00000001b*/
  73.  teFAutoScr = 0,                                        /*00000001b  obsolete. use teFAutoScroll*/
  74.  teFTextBuffering = 1,                                    /*00000010b*/
  75.  teFOutlineHilite = 2,                                    /*00000100b*/
  76.  teFInlineInput = 3,                                    /*00001000b  obsolete*/
  77.  teFUseTextServices = 4,                                /*00010000b  obsolete*/
  78.  
  79. /* action for the new "bit (un)set" interface, TEFeatureFlag */
  80.  TEBitClear = 0,
  81.  TEBitSet = 1                                            /*set the selector bit*/
  82. };
  83.  
  84. enum {
  85.  TEBitTest = -1,                                        /*no change; just return the current setting*/
  86.  
  87.  teBitClear = 0,
  88.  teBitSet = 1,                                            /*set the selector bit*/
  89.  teBitTest = -1,                                        /*no change; just return the current setting*/
  90.  
  91. /*constants for identifying the routine that called FindWord */
  92.  teWordSelect = 4,                                        /*clickExpand to select word*/
  93.  teWordDrag = 8,                                        /*clickExpand to drag new word*/
  94.  teFromFind = 12,                                        /*FindLine called it ($0C)*/
  95.  teFromRecal = 16,                                        /*RecalLines called it ($10)      obsolete */
  96.  
  97. /*constants for identifying DoText selectors */
  98.  teFind    = 0,                                            /*DoText called for searching*/
  99.  teHighlight = 1,                                        /*DoText called for highlighting*/
  100.  teDraw    = -1,                                            /*DoText called for drawing text*/
  101.  teCaret = -2                                            /*DoText called for drawing the caret*/
  102. };
  103.  
  104. typedef pascal Boolean (*WordBreakProcPtr)(Ptr text, short charPos);
  105. typedef pascal Boolean (*ClikLoopProcPtr)(void);
  106.  
  107. struct TERec {
  108.  Rect destRect;
  109.  Rect viewRect;
  110.  Rect selRect;
  111.  short lineHeight;
  112.  short fontAscent;
  113.  Point selPoint;
  114.  short selStart;
  115.  short selEnd;
  116.  short active;
  117.  WordBreakProcPtr wordBreak;
  118.  ClikLoopProcPtr clikLoop;
  119.  long clickTime;
  120.  short clickLoc;
  121.  long caretTime;
  122.  short caretState;
  123.  short just;
  124.  short teLength;
  125.  Handle hText;
  126. /* short recalBack;        */
  127. /* short recalLines;    */
  128.  long hDispatchRec;            /* added to replace recalBack & recalLines.  it's a handle anyway */
  129.  short clikStuff;
  130.  short crOnly;
  131.  short txFont;
  132.  Style txFace;                                            /*txFace is unpacked byte*/
  133.  char filler;
  134.  short txMode;
  135.  short txSize;
  136.  GrafPtr inPort;
  137.  ProcPtr highHook;
  138.  ProcPtr caretHook;
  139.  short nLines;
  140.  short lineStarts[16001];
  141. };
  142.  
  143. typedef struct TERec TERec;
  144. typedef TERec *TEPtr, **TEHandle;
  145.  
  146. typedef char Chars[32001];
  147. typedef char *CharsPtr,**CharsHandle;
  148.  
  149. struct StyleRun {
  150.  short startChar;                                        /*starting character position*/
  151.  short styleIndex;                                        /*index in style table*/
  152. };
  153.  
  154. typedef struct StyleRun StyleRun;
  155.  
  156. struct STElement {
  157.  short stCount;                                            /*number of runs in this style*/
  158.  short stHeight;                                        /*line height*/
  159.  short stAscent;                                        /*font ascent*/
  160.  short stFont;                                            /*font (family) number*/
  161.  Style stFace;                                            /*character Style*/
  162.  char filler;                                            /*stFace is unpacked byte*/
  163.  short stSize;                                            /*size in points*/
  164.  RGBColor stColor;                                        /*absolute (RGB) color*/
  165. };
  166.  
  167. typedef struct STElement STElement;
  168.  
  169. typedef STElement TEStyleTable[1777], *STPtr, **STHandle;
  170.  
  171. struct LHElement {
  172.  short lhHeight;                                        /*maximum height in line*/
  173.  short lhAscent;                                        /*maximum ascent in line*/
  174. };
  175.  
  176. typedef struct LHElement LHElement;
  177.  
  178. typedef LHElement LHTable[8001], *LHPtr, **LHHandle;    /* ARRAY [0..8000] OF LHElement */
  179.  
  180. struct ScrpSTElement {
  181.  long scrpStartChar;                                    /*starting character position*/
  182.  short scrpHeight;                                        /*starting character position*/
  183.  short scrpAscent;
  184.  short scrpFont;
  185.  Style scrpFace;                                        /*unpacked byte*/
  186.  char filler;                                            /*scrpFace is unpacked byte*/
  187.  short scrpSize;
  188.  RGBColor scrpColor;
  189. };
  190.  
  191. typedef struct ScrpSTElement ScrpSTElement;
  192.  
  193. typedef ScrpSTElement ScrpSTTable[1601];                /* ARRAY [0..1600] OF ScrpSTElement */
  194.  
  195. struct StScrpRec {
  196.  short scrpNStyles;                                        /*number of styles in scrap*/
  197.  ScrpSTTable scrpStyleTab;                                /*table of styles for scrap*/
  198. };
  199.  
  200. typedef struct StScrpRec StScrpRec;
  201. typedef StScrpRec *StScrpPtr, **StScrpHandle;
  202.  
  203. struct NullStRec {
  204.  long teReserved;                                        /*reserved for future expansion*/
  205.  StScrpHandle nullScrap;                                /*handle to scrap style table*/
  206. };
  207.  
  208. typedef struct NullStRec NullStRec;
  209. typedef NullStRec *NullStPtr, **NullStHandle;
  210.  
  211. struct TEStyleRec {
  212.  short nRuns;                                            /*number of style runs*/
  213.  short nStyles;                                            /*size of style table*/
  214.  STHandle styleTab;                                        /*handle to style table*/
  215.  LHHandle lhTab;                                        /*handle to line-height table*/
  216.  long teRefCon;                                            /*reserved for application use*/
  217.  NullStHandle nullStyle;                                /*Handle to style set at null selection*/
  218.  StyleRun runs[8001];                                    /*ARRAY [0..8000] OF StyleRun*/
  219. };
  220.  
  221. typedef struct TEStyleRec TEStyleRec;
  222. typedef TEStyleRec *TEStylePtr, **TEStyleHandle;
  223.  
  224. struct TextStyle {
  225.  short tsFont;                                            /*font (family) number*/
  226.  Style tsFace;                                            /*character Style*/
  227.  char filler;                                            /*tsFace is unpacked byte*/
  228.  short tsSize;                                            /*size in point*/
  229.  RGBColor tsColor;                                        /*absolute (RGB) color*/
  230. };
  231.  
  232. typedef struct TextStyle TextStyle;
  233. typedef TextStyle *TextStylePtr, **TextStyleHandle;
  234.  
  235.  
  236. typedef short TEIntHook;
  237.  
  238. #ifdef __cplusplus
  239. extern "C" {
  240. #endif
  241. pascal void TEInit(void)
  242.  = 0xA9CC; 
  243. pascal TEHandle TENew(const Rect *destRect,const Rect *viewRect)
  244.  = 0xA9D2; 
  245. pascal void TEDispose(TEHandle hTE)
  246.  = 0xA9CD; 
  247. pascal void TESetText(const void *text,long length,TEHandle hTE)
  248.  = 0xA9CF; 
  249. pascal CharsHandle TEGetText(TEHandle hTE)
  250.  = 0xA9CB; 
  251. pascal void TEIdle(TEHandle hTE)
  252.  = 0xA9DA; 
  253. pascal void TESetSelect(long selStart,long selEnd,TEHandle hTE)
  254.  = 0xA9D1; 
  255. pascal void TEActivate(TEHandle hTE)
  256.  = 0xA9D8; 
  257. pascal void TEDeactivate(TEHandle hTE)
  258.  = 0xA9D9; 
  259. pascal void TEKey(short key,TEHandle hTE)
  260.  = 0xA9DC; 
  261. pascal void TECut(TEHandle hTE)
  262.  = 0xA9D6; 
  263. pascal void TECopy(TEHandle hTE)
  264.  = 0xA9D5; 
  265. pascal void TEPaste(TEHandle hTE)
  266.  = 0xA9DB; 
  267. pascal void TEDelete(TEHandle hTE)
  268.  = 0xA9D7; 
  269. pascal void TEInsert(const void *text,long length,TEHandle hTE)
  270.  = 0xA9DE; 
  271. pascal void TESetAlignment(short just,TEHandle hTE)
  272.  = 0xA9DF; 
  273. pascal void TESetJust(short just,TEHandle hTE)
  274.  = 0xA9DF; 
  275. pascal void TEUpdate(const Rect *rUpdate,TEHandle hTE)
  276.  = 0xA9D3; 
  277. pascal void TETextBox(const void *text,long length,const Rect *box,short just)
  278.  = 0xA9CE; 
  279. pascal void TextBox(const void *text,long length,const Rect *box,short just)
  280.  = 0xA9CE; 
  281. pascal void TEScroll(short dh,short dv,TEHandle hTE)
  282.  = 0xA9DD; 
  283. pascal void TESelView(TEHandle hTE)
  284.  = 0xA811; 
  285. pascal void TEPinScroll(short dh,short dv,TEHandle hTE)
  286.  = 0xA812; 
  287. pascal void TEAutoView(Boolean fAuto,TEHandle hTE)
  288.  = 0xA813; 
  289. #define TEScrapHandle() (* (Handle*) 0xAB4)
  290. pascal void TECalText(TEHandle hTE)
  291.  = 0xA9D0; 
  292. pascal short TEGetOffset(Point pt,TEHandle hTE)
  293.  = 0xA83C; 
  294. pascal Point TEGetPoint(short offset,TEHandle hTE)
  295.  = {0x3F3C,0x0008,0xA83D}; 
  296. pascal void TEClick(Point pt,Boolean fExtend,TEHandle h)
  297.  = 0xA9D4; 
  298. pascal TEHandle TEStylNew(const Rect *destRect,const Rect *viewRect)
  299.  = 0xA83E; 
  300. pascal TEHandle TEStyleNew(const Rect *destRect,const Rect *viewRect)
  301.  = 0xA83E; 
  302. pascal void SetStylHandle(TEStyleHandle theHandle,TEHandle hTE)
  303.  = {0x3F3C,0x0005,0xA83D}; 
  304. pascal void SetStyleHandle(TEStyleHandle theHandle,TEHandle hTE)
  305.  = {0x3F3C,0x0005,0xA83D}; 
  306. pascal void TESetStyleHandle(TEStyleHandle theHandle,TEHandle hTE)
  307.  = {0x3F3C,0x0005,0xA83D}; 
  308. pascal TEStyleHandle GetStylHandle(TEHandle hTE)
  309.  = {0x3F3C,0x0004,0xA83D}; 
  310. pascal TEStyleHandle GetStyleHandle(TEHandle hTE)
  311.  = {0x3F3C,0x0004,0xA83D}; 
  312. pascal TEStyleHandle TEGetStyleHandle(TEHandle hTE)
  313.  = {0x3F3C,0x0004,0xA83D}; 
  314. pascal void TEGetStyle(short offset,TextStyle *theStyle,short *lineHeight,
  315.  short *fontAscent,TEHandle hTE)
  316.  = {0x3F3C,0x0003,0xA83D}; 
  317. pascal void TEStylPaste(TEHandle hTE)
  318.  = {0x3F3C,0x0000,0xA83D}; 
  319. pascal void TEStylePaste(TEHandle hTE)
  320.  = {0x3F3C,0x0000,0xA83D}; 
  321. pascal void TESetStyle(short mode,const TextStyle *newStyle,Boolean fRedraw,
  322.  TEHandle hTE)
  323.  = {0x3F3C,0x0001,0xA83D}; 
  324. pascal void TEReplaceStyle(short mode,const TextStyle *oldStyle,const TextStyle *newStyle,
  325.  Boolean fRedraw,TEHandle hTE)
  326.  = {0x3F3C,0x0002,0xA83D}; 
  327. pascal StScrpHandle TEGetStyleScrapHandle(TEHandle hTE)
  328.  = {0x3F3C,0x0006,0xA83D}; 
  329. pascal StScrpHandle GetStylScrap(TEHandle hTE)
  330.  = {0x3F3C,0x0006,0xA83D}; 
  331. pascal StScrpHandle GetStyleScrap(TEHandle hTE)
  332.  = {0x3F3C,0x0006,0xA83D}; 
  333. pascal void TEStylInsert(const void *text,long length,StScrpHandle hST,
  334.  TEHandle hTE)
  335.  = {0x3F3C,0x0007,0xA83D}; 
  336. pascal void TEStyleInsert(const void *text,long length,StScrpHandle hST,
  337.  TEHandle hTE)
  338.  = {0x3F3C,0x0007,0xA83D}; 
  339. pascal long TEGetHeight(long endLine,long startLine,TEHandle hTE)
  340.  = {0x3F3C,0x0009,0xA83D}; 
  341. pascal Boolean TEContinuousStyle(short *mode,TextStyle *aStyle,TEHandle hTE)
  342.  = {0x3F3C,0x000A,0xA83D}; 
  343. pascal void SetStylScrap(long rangeStart,long rangeEnd,StScrpHandle newStyles,
  344.  Boolean redraw,TEHandle hTE)
  345.  = {0x3F3C,0x000B,0xA83D}; 
  346. pascal void SetStyleScrap(long rangeStart,long rangeEnd,StScrpHandle newStyles,
  347.  Boolean redraw,TEHandle hTE)
  348.  = {0x3F3C,0x000B,0xA83D}; 
  349. pascal void TEUseStyleScrap(long rangeStart,long rangeEnd,StScrpHandle newStyles,
  350.  Boolean fRedraw,TEHandle hTE)
  351.  = {0x3F3C,0x000B,0xA83D}; 
  352. pascal void TECustomHook(TEIntHook which,ProcPtr *addr,TEHandle hTE)
  353.  = {0x3F3C,0x000C,0xA83D}; 
  354. pascal long TENumStyles(long rangeStart,long rangeEnd,TEHandle hTE)
  355.  = {0x3F3C,0x000D,0xA83D}; 
  356. pascal short TEFeatureFlag(short feature,short action,TEHandle hTE)
  357.  = {0x3F3C,0x000E,0xA83D}; 
  358. #define TEGetScrapLength() ((long) * (unsigned short *) 0x0AB0)
  359. #define TEGetScrapLen() ((long) * (unsigned short *) 0x0AB0)
  360. pascal void TESetScrapLength(long length); 
  361. pascal void TESetScrapLen(long length); 
  362. pascal OSErr TEFromScrap(void); 
  363. pascal OSErr TEToScrap(void); 
  364. pascal void TESetClickLoop(ClikLoopProcPtr clikProc,TEHandle hTE); 
  365. pascal void SetClikLoop(ClikLoopProcPtr clikProc,TEHandle hTE); 
  366. pascal void TESetWordBreak(WordBreakProcPtr wBrkProc,TEHandle hTE); 
  367. pascal void SetWordBreak(WordBreakProcPtr wBrkProc,TEHandle hTE); 
  368. void teclick(Point *pt,Boolean fExtend,TEHandle h); 
  369. #ifdef __cplusplus
  370. }
  371. #endif
  372.  
  373. #endif
  374.